package cate.common.table.farm.udgpalace.sheet;

import cate.common.table.ESheet;
import cate.common.table.d.GDUdgPalace;
import cate.common.table.farm.udgpalace.row.UdgPalaceEventRow;
import cate.common.table.item.rune.SkillGroupList;
import cate.common.util.random.RWList;
import org.apache.commons.collections4.CollectionUtils;

import java.util.List;

public class UdgPalaceEventSheet extends ESheet<UdgPalaceEventRow> {
    @Override
    public String getSheetName() {
        return "地宫探险事件组";
    }

    public GDUdgPalace.EventType randomEvent(int eventGroup, List<Integer> excludes) {
        UdgPalaceEventRow eventRow = get(eventGroup);
        if (eventRow != null) {
            if (CollectionUtils.isEmpty(excludes)) {
                return GDUdgPalace.EventType.transEventType(eventRow.eventGroup.get().getGroupId().get(0));
            }
            RWList<SkillGroupList.Item> list = new RWList<>();
            for (SkillGroupList.Item item : eventRow.eventGroup.list) {
                if (excludes.contains(item.getGroupId().get(0))) {
                    continue;
                }
                list.add(item);
            }
            if (!list.isEmpty()) {
                return GDUdgPalace.EventType.transEventType(list.setup().get().getGroupId().get(0));
            }
        }
        return GDUdgPalace.EventType.NONE;
    }
}
